package br.unb.mestrado.simulator.model.simulator.formula;

import br.unb.mestrado.simulator.model.simulator.formula.GoalParameter.GoalParameterType;


public class GoalFormula extends QualityFormula{

	private GoalParameter quality;
	private GoalParameter quantity;
	private GoalParameter lifetime;
	private GoalParameter reliability;
	private GoalParameter sample;
	
	public GoalParameter getQuality() {
		if(quality!=null){
			quality.setType(GoalParameterType.QUALITY);
		}
		return quality;
	}
	public void setQuality(GoalParameter quality) {
		this.quality = quality;
	}
	public GoalParameter getQuantity() {
		if(quantity!=null){
			quantity.setType(GoalParameterType.QUANTITY);
		}
		return quantity;
	}
	public void setQuantity(GoalParameter quantity) {
		this.quantity = quantity;
	}
	public GoalParameter getLifetime() {
		if(lifetime!=null){
			lifetime.setType(GoalParameterType.LIFETIME);
		}
		return lifetime;
	}
	public void setLifetime(GoalParameter lifetime) {
		this.lifetime = lifetime;
	}
	public GoalParameter getReliability() {
		if(reliability!=null){
			reliability.setType(GoalParameterType.RELIABILITY);
		}
		return reliability;
	}
	public void setReliability(GoalParameter reliability) {
		this.reliability = reliability;
	}
	
	public GoalParameter getSample() {
		if(sample!=null){
			sample.setType(GoalParameterType.SAMPLE);
		}
		return sample;
	}
	public void setSample(GoalParameter sample) {
		this.sample = sample;
	}
	
	public GoalParameter[] getParameters(){
		return new GoalParameter[]{getQuality(), getQuantity(), getLifetime(), getReliability(), getSample()};
	}
	
	public static String[] getParamaterLabel(){
		return new String[]{"Qual","Quant","Life","Relia","Samp"};	
	}
	
	public static int getParamaterCount(){
		return 5;	
	}
	
	@Override
	public String toString() {
		return " GOA (Prio, Norm, Mod, High) Conf(" + reliability
				+ ") Qual(" + quality + ") Quan(" + quantity
				+ ") Bat(" + lifetime + ") Amos(" + sample + ")";

	}
	public GoalParameter getPriorityParameter(int j) {
		GoalParameter[] parameters = getParameters();
		for (int i = 0; i < parameters.length; i++) {
			if(parameters[i].getPriority()==(j+1)){
				return parameters[i]; 
			}
		}
		return null;
	}
	
}
